from django.contrib.auth.models import AbstractUser
from django.db import models


# Create your models here.
class Visitor(models.Model):
    status = models.SmallIntegerField(default=0)
    ctype = models.CharField(max_length=20, verbose_name="证件类型")
    cid = models.CharField(max_length=20, verbose_name="证件号")
    name = models.CharField(max_length=20, verbose_name="姓名")
    phone = models.CharField(max_length=20, verbose_name="手机号")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")  # auto_now_add=True 自动添加时间，更新对象时不会有变化
    updated_at = models.DateTimeField(auto_now=True, verbose_name="最后一次修改的时间")  # auto_now 自动添加时间，每次修改时更新

    class Meta:
        verbose_name = "访客管理"
        verbose_name_plural = verbose_name


class Appointment(models.Model):
    order_date = models.CharField(max_length=20, verbose_name="预约日期")
    order_time = models.CharField(max_length=20, verbose_name="预约时段")
    uid = models.CharField(max_length=20, verbose_name="预约用户ID")
    visitor_id = models.CharField(max_length=20, verbose_name="访客ID")
    status = models.SmallIntegerField(choices=((0, "未到访"), (1, "已到访"), (2, "已离场")), verbose_name="状态")
    created_at = models.DateTimeField(auto_now_add=True, verbose_name="创建时间")  # auto_now_add=True 自动添加时间，更新对象时不会有变化
    updated_at = models.DateTimeField(auto_now=True, verbose_name="最后一次修改的时间")  # auto_now 自动添加时间，每次修改时更新

    class Meta:
        verbose_name = "预约管理"
        verbose_name_plural = verbose_name


class User(AbstractUser):
    avatar = models.CharField(max_length=255, null=True, verbose_name="头像")
    phone_number = models.CharField(max_length=11, null=True, verbose_name="手机号")
    status = models.IntegerField(null=True, default=0, verbose_name="帐号状态（0正常，1停用）")
    openid = models.CharField(max_length=200, null=True, verbose_name="微信ID")
    remark = models.CharField(max_length=1024, null=True, verbose_name="备注")

    class Meta:
        verbose_name = "用户管理"
        verbose_name_plural = verbose_name
